package com.wz.wiki.job;

import com.wz.wiki.mapper.DocMapper;
import com.wz.wiki.service.DocService;
import com.wz.wiki.utils.SnowFlake;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author 王哲
 * @Contact 1121586359@qq.com
 * @ClassName DocJob.java
 * @create 2023年07月03日 下午3:28
 * @Description 同步Ebook信息的定时任务
 * @Version V1.0
 */
@Component
public class DocJob {

    private static final Logger LOG = LoggerFactory.getLogger(DocJob.class);

    @Resource
    private DocService docService;

    @Resource
    private SnowFlake snowFlake;

    // 每30s启动一次
     @Scheduled(cron = "0/30 * * * * ?")
    public void cron() {
         // 增加日志流水号
         MDC.put("LOG_ID", String.valueOf(snowFlake.nextId()));
         LOG.info("更新电子书下的文档数据开始");
         docService.updateEbookInfo();
         LOG.info("更新电子书信息成功");
    }

}
